[Go] Fix for #3441 and #3443 -- expose Reset() and String() methods.#3548
[Go] Fix for #3441 and #3443 -- expose Reset() and String() methods.#3548
Conversation
| next(t, lexer, "[@-1,9:9=' ',<7>,1:9]") | ||
| next(t, lexer, "[@-1,10:10='3',<2>,1:10]") | ||
| next(t, lexer, "[@-1,11:10='<EOF>',<-1>,1:11]") | ||
| } |
There was a problem hiding this comment.
Should it be a test on Reset method as well?
There was a problem hiding this comment.
Yeah, looks like I missed that. Thanks.
|
Waiting for #3558 |
|
Guys - I have fixed this in the /v4 code, where it should be - I used this code and added the new test file (though really, those test files are useless and I need to actually add some tests. The build tests are adequate for now, but there is supposed to be a test suite in the actual go runtime itself . What is there right now is just a few half-hearted tests that don't really help anything. Anyway, you can close this PR now as I have used @kaby76 Ken's code and put it in the /v4 code. That PR will come in shortly and close the issues that this PR was correctly addressing. |
What does this PR fix?
Discussion
This is a fix for the missing API method String() in the Token, and Reset() in the Lexer.
Go requires any exported data or functions to be capitalized. These functions are required for this code to print out the token stream:
IToken.ToString() in C# and Token.toString() in Java are available because whatever implementation is used, it is derived from
object. Thus, in C#, you can dot.ToString()or Java,t.toString(). Yet,t.String()in Go causes a compilation error.Reset() in C# and reset() in Java are explicitly listed
publicin the interface. Thus, in C#, you can dolexer.Reset();, and Java,lexer.reset();. Yet,lexer.Reset()orlexer.reset()in Go results in a compilation error.The change is renames two methods. I've included a test in the runtime for the two methods.
Why is this PR important?
grammars-v4 CI tests most of the Antlr targets on a per-commit basis. The CI testing has pointed to many important bugs in Antlr. When a difference in parsing is detected, we need ways to easily compare the computations of the target with other targets. A print out of the tokens during the parse is absolutely essential in discovering why a parser target is not working.